<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,com.onlineMIS.ORM.entity.headQ.supplier.finance.SupplierAcctFlowReportItem"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>禧乐仓连锁店管理信息系统</title>
<%@ include file="../../../common/Style.jsp"%>
<script>
var ITEM_TYPE_P = "<%=SupplierAcctFlowReportItem.ITEM_TYPE_PURCHASE%>";
var ITEM_TYPE_F = "<%=SupplierAcctFlowReportItem.ITEM_TYPE_FINANCE%>";
$(document).ready(function(){
	parent.$.messager.progress('close'); 

	var params= $.serializeObject($('#SalesOrderSearchForm'));
	
	$('#dataGridSup').datagrid({
		url : 'financeSupplierJSON!searchAcctFlow',
		queryParams: params,
		fit : true,
		fitColumns : true,
		border : false,
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect:true,
		rownumbers:true,
		nowrap : false,
		columns : [ [
					{field:'date', width:60,title:'单据日期'},
					{field:'supplierName', width:150,title:'供应商',fixed:true,
						formatter: function (value, row, index){
							return row.supplier.name;
						}},
					{field:'itemTypeName', width:60,title:'单据种类'},
					{field:'quantity', width:60,title:'单据数量',
						formatter: function (value, row, index){
							return parseQuantity(row.quantity);
						}},
					{field:'amount', width:50,title:'单据金额',
							formatter: function (value, row, index){
								return parseNumberValue(row.amount);
							}},
					{field:'comment', width:80,title:'单据摘要'},
					{field:'acctIncrease', width:60,title:'应付增加',
						formatter: function (value, row, index){
							return parseNumberValue(row.acctIncrease);
						}},
					{field:'acctDecrease', width:65,title:'应付减少',
						formatter: function (value, row, index){
							return parseNumberValue(row.acctDecrease);
						}},
					{field:'postAcct', width:90,title:'+应付/-应收金额',
						formatter: function (value, row, index){
							return (row.postAcct).toFixed(1);
						}},
					{field:'action', width:65,title:'详情',
						formatter: function (value, row, index){
							var url = "";
							var id = row.id;
							if (row.itemType == ITEM_TYPE_P)
								  url = "supplierPurchaseJSP!getPurchaseOrder?formBean.order.id=" + id ;
							else if (row.itemType == ITEM_TYPE_F)
								  url = "financeSupplierJSP!getFHQ?formBean.order.id="+id;
							
							var str = '';
							if (row.id != 0)
							    str += $.formatString('<a href="#" onclick="addTab3(\'{0}\',\'{1}\');"><img border="0" src="{2}" title="查看"/></a>', url, row.itemTypeName+id, '<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update.png' );
							return str;
						}}
			     ]],
				toolbar : '#toolbarSup',
		});
	});

function searchAcctFlow(){
	
	var params= $.serializeObject($('#SalesOrderSearchForm'));
	$('#dataGridSup').datagrid('load',params); 
}
function changeChainStore(chainId){

}
function downloadAcctFlow(){
	
	document.SalesOrderSearchForm.action="financeSupplierJSP!downloadSupplierFHQBill";
	document.SalesOrderSearchForm.submit();
}
</script>
</head>
<body>
	
	
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 125px;">
	<s:form id="SalesOrderSearchForm" name="SalesOrderSearchForm"
		action="/actionChain/salesAction!searchOrders" 
		theme="simple" method="POST">
		<table width="98%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td height="50" colspan="7">
								<div class="errorAndmes">
									<s:actionerror cssStyle="color:red" />
									<s:actionmessage cssStyle="color:blue" />
								</div>
								<table width="100%" border="0">
									<tr class="PBAOuterTableTitale">
										<td height="35" colspan="6">供应商财务往来账目:
										</td>
									</tr>
									<tr>
										<td width="20%"><%@ include file="../SupplierInput.jsp"%><input type="hidden" id="indicator" name="formBean.indicator" value="-1"/></td>

										<td width="20%"><strong>单据日期：  </strong><s:textfield id="startDate"
											name="formBean.searchStartTime" cssClass="easyui-datebox"
											data-options="width:100,editable:false" /> &nbsp; 至&nbsp; <s:textfield
											id="endDate" name="formBean.searchEndTime" cssClass="easyui-datebox"
											data-options="width:100,editable:false" /></td>
										<td width="15%"><strong>单据摘要：</strong><s:textfield name="formBean.order.comment" data-options="prompt:'请输入单据摘要'" id="comment" size="25" cssClass="easyui-textbox" /></td>
										<td width="4%"  align="center"><strong>标签名称:</strong></td>
										<td  align="left"><s:select size="1" cssClass="easyui-combobox"
														style="width:180px" id="tagId" list="uiBean.tags"
														listKey="id" name="formBean.tagId" listValue="tagName" /></td>
									</tr>															
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</s:form>
	</div>
			<div data-options="region:'center',border:false">
			
			<div id="toolbarSup" style="display: none;">
				<a onclick="searchAcctFlow();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true">查询账目</a> <a
					onclick="downloadAcctFlow();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-print',plain:true">下载账目</a>
			</div>
			<table id="dataGridSup">
			</table>
		</div>
</div>	
</body>
</html>